{
try
{
- const auto stdStrPath = _path.toStdWString();
- _initialPermissions = FileSystem::isFolderReadOnly(stdStrPath) ? OCC::FileSystem::FolderPermissions::ReadOnly : OCC::FileSystem::FolderPermissions::ReadWrite;
- if (_initialPermissions != temporaryPermissions) {
+ const auto &stdStrPath = _path.toStdWString();
+ const auto fsPath = std::filesystem::path{stdStrPath};
+ if ((temporaryPermissions == OCC::FileSystem::FolderPermissions::ReadOnly && !FileSystem::isFolderReadOnly(fsPath)) ||
+ (temporaryPermissions == OCC::FileSystem::FolderPermissions::ReadWrite && FileSystem::isFolderReadOnly(fsPath))) {
+ FileSystem::setFolderPermissions(_path, temporaryPermissions);
_rollbackNeeded = true;
}
- FileSystem::setFolderPermissions(_path, temporaryPermissions);
}
catch (const std::filesystem::filesystem_error &e)
{
//4. File should be updated, that's tested by assertLocalAndRemoteDir
QCOMPARE(currentLocalState.find("normalDirectory_PERM_CKDNV_/canBeModified_PERM_W_.data")->size, canBeModifiedSize + 1);
-#if defined Q_OS_WINDOWS
- QCOMPARE(currentLocalState.find("readonlyDirectory_PERM_M_/canBeModified_PERM_W_.data")->size, canBeModifiedSize);
-#else
QCOMPARE(currentLocalState.find("readonlyDirectory_PERM_M_/canBeModified_PERM_W_.data")->size, canBeModifiedSize + 1);
-#endif
//5.
// the file should be in the server and local